#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
const int MAXN=2e5+10;
struct node {
	int rank,pre,data;
} 	a[MAXN];
vector <int> ans;
int main() {
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",&a[i].data);
		a[i].rank=i,a[i].pre=i-1;
	}
	a[0].data=2;
	int cnt=n,tail=n+1;
	a[tail].pre=n;
	while(cnt!=0) {
		for(int i=tail;i;i=a[i].pre) {
			while(a[a[a[i].pre].pre].data!=a[a[i].pre].data) {
				ans.push_back(a[a[i].pre].rank);
				a[a[i].pre].data=-1;
				--cnt;
				a[i].pre=a[a[i].pre].pre;
			}
		}
		for(int i=ans.size()-1;i>=0;--i) {
			printf("%d ",ans[i]);
		}
		ans.clear();
		puts("");
	}
	return 0;
}
